<%--
  Created by IntelliJ IDEA.
  User: 62585
  Date: 2021/4/11
  Time: 18:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>员工列表</title>

    <!-- Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
</head>
<body>
<%
    request.setAttribute("ctp", request.getContextPath());
%>
<div class="container">
    <%--  标题  --%>
    <div class="row">
        <%--     占5列   --%>
        <div class="col-md-5">
            <h1>SSM - CURD</h1>
        </div>
    </div>
    <%--  增删  --%>
    <div class="row">
        <div class="col-md-4 col-md-offset-8">
            <button type="button" class="btn btn-primary">
                <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
                新增
            </button>
            <button type="button" class="btn btn-danger">
                <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
                删除
            </button>
        </div>
    </div>
    <%--  表格  --%>
    <div class="row">
        <table class="table table-hover">
            <tr>
                <th>#</th>
                <th>姓名</th>
                <th>性别</th>
                <th>电子邮件</th>
                <th>部门名</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${pageInfo.list}" var="emp">
                <tr>
                    <td>${emp.empId}</td>
                    <td>${emp.empName}</td>
                    <td>${emp.email}</td>
                    <td>${emp.gender == "male" ? "男":"女"}</td>
                    <td>${emp.department.deptName}</td>
                    <td>
                        <button type="button" class="btn btn-info btn-sm">
                            <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                            修改
                        </button>
                        <button type="button" class="btn btn-danger btn-sm">
                            <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
                            删除
                        </button>
                    </td>
                </tr>
            </c:forEach>
        </table>
    </div>
    <%--  页码  --%>
    <div class="row">
        <div class="col-md-4 col-md-offset-1">
            当前第<span class="label label-default">${pageInfo.pageNum}</span>
            页，共有<span class="label label-default">${pageInfo.pages}</span>
            页，总计<span class="label label-default">${pageInfo.total}</span>
            条记录
        </div>
        <div class="col-md-5 col-md-offset-7">
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <li><a href="${requestScope.ctp}/getEmps?pn=${1}"></a>首页</li>
                    <li>
                        <c:if test="${!pageInfo.isFirstPage}">
                            <a href="${requestScope.ctp}/getEmps?pn=${pageInfo.pageNum-1}" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </c:if>
                        <c:if test="${pageInfo.isFirstPage}">
                            <a href="#" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </c:if>
                    </li>
                    <c:forEach items="${pageInfo.navigatepageNums}" var="pageNum">
                        <c:if test="${pageNum == pageInfo.pageNum}">
                            <li class="active"><a href="${requestScope.ctp}/getEmps?pn=${pageNum}">${pageNum}</a></li>
                        </c:if>
                        <c:if test="${pageNum != pageInfo.pageNum}">
                            <li><a href="${requestScope.ctp}/getEmps?pn=${pageNum}">${pageNum}</a></li>
                        </c:if>
                    </c:forEach>
                    <li>
                        <c:if test="${!pageInfo.isLastPage}">
                            <a href="${requestScope.ctp}/getEmps?pn=${pageInfo.pageNum+1}" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </c:if>
                        <c:if test="${pageInfo.isLastPage}">
                            <a href="#" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </c:if>
                    </li>
                    <li><a href="${requestScope.ctp}/getEmps?pn=${pageInfo.total}">尾页</a></li>
                </ul>
            </nav>
        </div>
    </div>
</div>
</body>
</html>
